[bits 16]
; Switch to protected mode

switch_to_pm:
  cli			; Switch off interrupts
  
  lgdt [gdt_descriptor] ; Load the global descriptor table
  
  mov eax, cr0		; Switch to pm
  or eax, 0x1  		; by setting the first byte of
  mov cr0, eax		; cr0 to 1

  jmp CODE_SEG:init_pm  ; make the far jump


[bits 32]
; Initialise segment registers

init_pm:
  mov ax, DATA_SEG
  mov ds, ax
  mov ss, ax
  mov es, ax
  mov fs, ax
  mov gs, ax

  mov ebp, 0x90000
  mov esp, ebp

  call begin_pm
